package bqds

import (
	"fmt"
	"strconv"
)

func PrepareSql() {
	// s 是 insert table_name(field list)values(%1)中的字段列表
	s := []string{"AccountID", "BrokerID", "InvestorID", "Credit", "Deposit", "Withdraw", "PreDeposit", "PreMargin", "PreBalance",
		"CurrMargin", "CashIn", "Balance", "Available", "Commission", "CloseProfit", "PositionProfit", "FrozenCash", "FrozenCommission",
		"ExchangeMargin", "DeliveryMargin", "ExchangeDeliveryMargin", "ReserveBalance"}
	s = []string{"AccountID", "BrokerID", "InvestorID", "InstrumentID", "datetime", "CloseAmount", "CloseProfit", "CloseProfitByDate",
		"CloseProfitByTrade", "TodayPosition", "YdPosition", "Position", "UseMargin", "PreMargin", "PositionCost", "FrozenMargin", "FrozenCash",
		"PositionCostOffset", "FrozenCommission", "CashIn", "Commission", "PreSettlementPrice", "PositionDirection", "OpenCost", "OpenVolume",
		"CloseVolume", "ExchangeMargin", "OpenAmount"}
	s = []string{"InvestorId", "BrokerID", "InstrumentID", "ExchangeID", "StatusMsg", "OrderRef", "OrderSysID", "LastTradeTime", "InsertDate", "InsertTime", "CancelTime", "Direction", "OffsetFlag", "LimitPrice", "RequestID", "Volume", "VolumeTotalOriginal", "VolumeTraded", "VolumeLeft", "FrontID", "SessionID", "IsLocal"}
	s = []string{"InvestorId", "BrokerID", "InstrumentID", "ExchangeID", "TradeID", "OrderRef", "OrderSysID", "TradeDate", "TradeTime", "TradingDay", "Direction", "OffsetFlag", "Price", "Volume"}
	var s1 []string
	values := "values("
	sql := `insert into account."order"(`
	pp := "Prepare("
	for n, v := range s {
		// fmt.Println(v)
		s1 = append(s1, "df[\""+v+"\"],")
		sql = sql + "\"" + v + "\"" + ","
		values = values + "$" + strconv.FormatInt((int64)(n+1), 10) + ","
		pp = pp + "df[\"" + v + "\"],"
	}
	sql = sql[0:len(sql)-1] + ")" + values[0:len(values)-1] + ")"
	pp = pp[0:len(pp)-1] + ")"
	fmt.Println(pp)
	fmt.Println(sql)
}
